<template>
	<tm-app ref="app">
		
		<!-- 优秀伴学员 优秀帮手  更多>> -->
		<view class="pd40" style="margin-top:-20rpx;">
			<!--<view style='margin-top:0rpx;'>
				<view class="goods-container">
					<view class="goo-title">
						<tm-text fontSize="30" _class='title-c' label="优秀帮手"></tm-text>
					</view>
					<view class='multigroup-more'>
						<text label="更多>>" @click="searchPage()">更多>></text>
					</view>
				</view>
			</view>-->
			<view class="goods-container flex-start">
				<view class="goods-box" :key="index" v-for="(item,index) in imglist">
					<tm-image :height="300" :width="300" :src="item.img" @click="bsClick(item['id'])"></tm-image>
					<view class="pt-12 pb-12 px-12">
						<tm-text :label="item.name" _class="text-overflow-1"></tm-text>
						<tm-text style="font-weight: bold;" :label="item.school" _class="text-overflow-1"></tm-text>
					</view>
				</view>
			</view>
		</view>
		
		

		


		<tm-tabbar :autoSelect="false" v-model:active="acc">
			<tm-tabbar-item @click="acc=0" activeColor="orange" url='/pages/index/index' open-type='reLaunch' text="home"
				icon='tmicon-md-home'></tm-tabbar-item>
			<tm-tabbar-item @click="acc=1" activeColor="orange" url='/pages/index/my' text="my" unicon="tmicon-account"
				icon="tmicon-userplus-fill"></tm-tabbar-item>
		</tm-tabbar>

		<tm-message ref="msg" :lines="2"></tm-message>
	</tm-app>
</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import { onLoad } from "@dcloudio/uni-app"
	import { isEmpty } from "@/tmui/tool/function/util";
	import { pageBangshouIndexShow } from "@/api/index"
	import { indexNews } from "@/api/news";
	import tmMessage from "@/tmui/components/tm-message/tm-message.vue";
	


	const msg = ref<InstanceType<typeof tmMessage> | null>(null);
	const acc = ref(0);
	const imglist = ref([]);
	const listimg = [
		"https://www.zhaobangyang.cn/img/2023/05/bg0.jpg",
		"https://www.zhaobangyang.cn/img/2023/05/bg1.jpg"
	];
	const newslist = ref([]);
	const showWin = ref(true);

	function clsDeig() {
		showWin.value = false;
	}


	function showPage(val : any) {
		if (val === 1) {
			uni.navigateTo({
				url: '/pages/my/bs'
			})
		}
		if (val === 2) {
			uni.navigateTo({
				url: '/pages/my/jz'
			})
		}

		if (val === 3) {
			uni.redirectTo({
				url: '/pages/index/order'
			})
		}

		if (val === 4) {
			// msg.show({model:'warn'}) 18067153248
			uni.makePhoneCall({
				phoneNumber: '18067153248' // 仅为示例
			});
		}
	}

	function searchBsGsPage() {
		uni.navigateTo({
			url: '/pages/news/list'
		})
	}

	function searchPage() {
		uni.navigateTo({
			url: '/pages/index/seach'
		})
	}


	onLoad(() => {
		loadBs();
		loadNews();
		let userid = uni.getStorageSync("userid");
		console.log(userid);
		console.log(userid.split('-').length);
		if(userid.split('-').length > 1){
			uni.setStorageSync("userid","");
			uni.navigateTo({
				url: '/pages/auth/auth'
			})
		}
		
		
	})

	const loadNews = async () => {
		const result = await indexNews();
		// console.log(JSON.stringify(result));
		newslist.value = result;
	}

	function loadNewsDetail(id : string) {
		// console.log(id);
		uni.navigateTo({
			url: `/pages/news/read?id=${id}`
		})
	}


	const loadBs = async () => {
		const result = await pageBangshouIndexShow();
		result.forEach(function (arr, index) {
			console.log(JSON.stringify(arr));
			imglist.value.push(arr);
		})
	}

	function bsClick(id : string) {
		uni.navigateTo({
			url: `/pages/detail/detail?id=${id}`
		})
	}
</script>



<style>
	.title-c {
		display: block;
		font-size: 32rpx;
		font-weight: 900;
		color: #333;
	}


	.goods-box {
		width: 47%;
		margin: 0% 1.5% 0.5em 1.5%;
		flex: none;
		overflow: hidden;
		box-sizing: border-box;
		border-radius: 0.3em;
		box-shadow: 2px 3px 15px #eee;
	}

	.goods-box image {
		width: 100%;
	}

	.goods-container {
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		box-sizing: border-box;
		/* background-color:#fff; */
		padding: 0 20rpx 20rpx 20rpx;
	}

	.goods-title {
		/* width: 343rpx; */
		text-overflow: ellipsis;
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		font-size: .9em;
		color: #333;
		padding: 0;
		line-height: 2.5;
		text-align: center;
	}

	.pd40 {
		background-color: #fff;
		width: 94%;
		padding: 0.8em .3% 0;
		margin: 1em auto 1em;
		border-radius: 0.3em;
		/*padding: 20rpx 20rpx 10rpx;*/
	}

	.multigroup-more {
		color: #999;
		border-radius: 44rpx;
		font-size: 0.85em;
		display: block;
		padding: 10rpx 15rpx;
		border: 0px solid #777;
	}

	.pd40 .goo-title {
		border-left: solid 0.25em #f39800;
		padding-left: 0.4em;
		margin-top: 0.2em;
		margin-bottom: 0.25em;
		color: #333;
		font-weight: 100;
	}

	.top-bg {
		height: 400rpx;
		width: 100%;
		background-repeat: no-repeat;
		background-size: cover;
		border-radius: 0 0 1em 1em;
		position: absolute;
		top: -2em;
	}

	.top-bg image {
		display: block;
		width: 100%;
		height: 180%;
		margin-top: 0;
	}

	.gonggao {
		width: 94%;
		padding: 0 1%;
		height: 2.5em;
		border-radius: 3em;
		background-color: #fff;
		margin: 0.5em auto 0;

	}

	.gonggao>view {
		float: left;
		text-align: center;
		width: 5em;
		line-height: 2.5em;
		color: #fff;
		font-weight: bold;
		background-color: #f39800;
		border-radius: 2em 0 0 2em;
	}

	.gonggao>view image {
		width: 3.6em;
		height: 2.5em;
		margin: 0 auto;
		display: block;
	}

	.gonggao text {
		line-height: 2.5em;
		margin-left: 0.5em;
	}

	.index-ad {
		height: 5.25em;
		width: 96%;
		margin: -.5em auto;
	}

	.index-ad image {
		width: 100%;
		height: 100%;
	}

	.in-list {}

	.in-list view {
		height: 2.5em;
		border-radius: 2em;
		width: 90%;
		margin: .8em auto;
		box-shadow: .3em .3em .3em rgba(0, 0, 0, .05);
		background-image: url(https://www.zhaobangyang.cn/img/base/border-sto.svg);
		background-position: right center;
		background-repeat: no-repeat;
	}

	.in-list>view:last-child {
		margin-bottom: 1.5em;
	}

	.in-list view image {
		width: 1em;
		height: 1em;
		margin: .8em .3em;
		border-radius: 50%;
		float: left;
	}


</style>